﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Hallenberg.SmartClient.MVC
{
    public sealed class NameResolver
    {
        private const string ControllerSuffix = "controller";

        private NameResolver()
        {
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "Parameter 'type' cannot have its type changed")]
        public static string GetControllerName(string className)
        {
            string controllerName = className;
            if (controllerName.EndsWith(ControllerSuffix, StringComparison.OrdinalIgnoreCase))
            {
                controllerName = controllerName.Substring(0, controllerName.Length - ControllerSuffix.Length);
            }

            return controllerName;
        }
    }
}
